package org.baicaix.game.warworms.Battle {
	import flash.display.DisplayObjectContainer;

	/**
	 * @author baicaix
	 */
	public class Camera {
		
		private static var _instance : Camera;

		private var _scene : DisplayObjectContainer;
//		private var _target : DisplayObject;
		
		private var width : Number;
		private var height : Number;
		
//		private var isLockon : Boolean; 
		
		public function Camera() {
		}
		
		public static function getInstance() : Camera {
			if(_instance == null) {
				_instance = new Camera();
			}
			return _instance;
		}
		
		public function init(width : Number, height : Number) : void {
			this.width = width;
			this.height = height;
		}

		//		public function lockon(target : DisplayObject) : BindableObject {
//			unlock();
//			isLockon = true;
//			_target = target;
//			var bindX : BindableObject = new BindableObject(_target.x);
//			bindX.bind(this, "x");
//			bindX.bind(this, "y");
//			return bindX;
//		}
//
//		private function unlock() : void {
//			if(!isLockon) return;
//				
//		}
		
		public function moveTo(x : Number, y : Number) : void {
//			unlock();	
			
			this.x = x;
			this.y = y;
		}
		
		public function set scene(scene : DisplayObjectContainer) : DisplayObjectContainer {
			_scene = scene;
			return _scene;
		}

		private function set x(x : Number) : void {
			_scene.x = -x + width / 2;				
		}
		
		private function set y(y : Number) : void {
			_scene.y = -y + height / 2;	
		}
	}
}
